package cn.cjxy.controller;

import cn.cjxy.domain.TitleHot;
import cn.cjxy.service.TitleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Calendar;
import java.util.List;

@RestController
@RequestMapping("/home")
public class HomeController {
    //依赖注入
    @Autowired
    private TitleService titleService;

    /**
     * 测试 时间范围查询
     * @return
     * @throws IOException
     */
    @RequestMapping("/hots")
    public List<TitleHot> hots() throws IOException {
        //构造起始时间
        Calendar instance = Calendar.getInstance();
        instance.set(Calendar.YEAR,2023);
        instance.set(Calendar.MONTH,1);
        instance.set(Calendar.DAY_OF_MONTH,1);
        //起始和结束
        return titleService.findByTimeStamp(instance.getTimeInMillis(),System.currentTimeMillis());

    }

}
